package com.ijunfu.spring.genBean._13_context_register_bean;

import com.ijunfu.spring.genBean._13_context_register_bean.config.AppConfig;
import com.ijunfu.spring.genBean._13_context_register_bean.utils.Helper;
import com.ijunfu.spring.genBean._13_context_register_bean.utils.JsonHelper;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 *
 * @Title  : 
 * @Author : ijunfu <ijunfu@163.com>
 * @Date   : 2023/11/10 16:34
 * @Version: 1.0
 * @Motto  : 世界很大 世界很小
 *
 */
public class ContextRegisterBeanMain {

    public static void main(String[] args) {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);

        context.registerBean("helper", Helper.class);

        Helper helper = context.getBean(Helper.class);
        helper.print();

        context.registerBean("jsonHelper", JsonHelper.class, ()->new JsonHelper());

        JsonHelper jsonHelper = (JsonHelper) context.getBean("jsonHelper");
        jsonHelper.print();
    }
}
